package com.tjetc.字节数组流;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;

public class T01字节数组流 {
    public static void main(String[] args) throws IOException {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        baos.write("世界你好".getBytes());
        byte[] bytes = baos.toByteArray();
        //字节数组输入流
        ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes);
        //创建大水杯,正好一次性的接收
        byte[] b = new byte[bytes.length];
        //一次性的接收
        byteArrayInputStream.read(b);
        //控制台显示
        System.out.println(new String(b));

    }
}
